package com.sylli.oeuf.server.object.transferable;

import com.sylli.oeuf.server.game.logic.BattleActor;
import com.sylli.oeuf.server.game.logic.BattleActorSource;
import com.sylli.oeuf.server.game.logic.Plan;

public class MonsterTO extends BasedTO implements BattleActorSource {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3312163058761523891L;
	
	private int monsterId;
	
	private String name;
	
	private int statHp;
	
	private int statMp;
	
	private StatTO stat;
	
	private int level;
	
	private int exp;
	
	private int flag;
	
	private StrategyBundleTO strategyBundle;
	
	public MonsterTO() {
		strategyBundle = new StrategyBundleTO();
	}
	
	@Override
	public String toString() {
		return "MonsterTO: monsterId=" + monsterId
			+ ", name="+ name
			+ ", statHp=" + statHp
			+ ", statMp=" + statMp
			+ ", stat=" + stat
			+ ", level=" + level
			+ ", exp=" + exp
			+ ", flag=" + flag
			+ ", strategy=" + strategyBundle;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof MonsterTO) {
			MonsterTO cgi = (MonsterTO) obj;
			return cgi.monsterId == monsterId
				&& cgi.name.equals(name)
				&& cgi.getStat().equals(stat)
				&& cgi.statHp == statHp
				&& cgi.statMp == statMp
				&& cgi.level == level
				&& cgi.exp == exp
				&& cgi.flag == flag
				&& cgi.strategyBundle.equals(strategyBundle);
		}
		return false;
	}
	
	@Override
	public Plan findPlan(int id) {
		if (getAvailablePlanCount()==0)
			return null;
		for (StrategyTO st : strategyBundle.getBundle()) {
			if (st.getStrategyId() == id) {
				return st.toGameLogicObject();
			}
		}
		return null;
	}
	
	public int getMonsterId() {
		return monsterId;
	}

	public void setMonsterId(int monsterId) {
		this.monsterId = monsterId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getStatHp() {
		return statHp;
	}

	public void setStatHp(int statHp) {
		this.statHp = statHp;
	}

	public int getStatMp() {
		return statMp;
	}

	public void setStatMp(int statMp) {
		this.statMp = statMp;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getExp() {
		return exp;
	}

	public void setExp(int exp) {
		this.exp = exp;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	@Override
	public void snapback(BattleActor actor) {
		// donot update.
		
	}

	public StatTO getStat() {
		return stat;
	}

	public void setStat(StatTO stat) {
		this.stat = stat;
	}

	public StrategyBundleTO getStrategyBundle() {
		return strategyBundle;
	}

	public void setStrategyBundle(StrategyBundleTO strategyBundle) {
		this.strategyBundle = strategyBundle;
	}

	@Override
	public int getAvailablePlanCount() {
		return strategyBundle.getBundle().size();
	}

}
